home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: kasslar@aol.com (Kasslar)
- Newsgroups: comp.lang.c++
- Subject: Re: OOD problem
- Date: 27 Feb 1996 14:32:50 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4gvm92$11u@newsbf02.news.aol.com>
- References: <4fvkmt$ems@reader2.ix.netcom.com>
- Reply-To: kasslar@aol.com (Kasslar)
- NNTP-Posting-Host: newsbf02.mail.aol.com
-
- As a design question it seems to me that if 'A' needs to know what kind of
- 'B' it is pointing to upon occasion then 'B's hierarchy can't do all of
- the work with polymorpism. 'A' must determine the specific type of 'B' at
- run time. This is always unpleasant but common enough to provide several
- popular solutions.
-
- You could, of course, use C++ RTTI or some compiler specific solution here
- but I prefer to avoid this. It sounds to me like your scenereo suffices
- with polymorphic behavior most of the time but presents the occasional
- caveat. For this prediciment I prefer keeping several pointers in A. One
- B*, one C*, one D* and one E*. When the object that B* points to is
- construced apply a specific pointer at the same time. This allows you to
- once again loose your concern for the specific type pointed to by B. Where
- polymorphic behavior does the trick use the B*. When you must make calls
- to specific subclass methods use the subclass pointers. If a particular
- subclass has no additional behavior you will require no pointer to its
- specific type. If a routine attempts to manipulate the B* object with an
- incorrect method it should find the pointer to the specific class to be
- NULL.
-
- It's not a perfect solution but it cleans up the many instances of RTTI
- interrogation that yould otherwise go on and runs faster too.
-
- Just MHO,
- Randy Abernethy
- ----------------------------------------
- Randy Abernethy
- Kasslar Enterprises
- kasslar@aol.com
- randya@spectralinc.com
- rabernethy@spectralinc.com
- ----------------------------------------
-